﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace DHQGHN.PM0.Models.Admin
{
    public class BloodGroupModel
    {
        public string Blood_Group_ID { get; set; }

        [Remote("CheckExistBloodGroupName", "BloodGroup", ErrorMessage = "BloodGroupNameExist", HttpMethod = "POST", AdditionalFields = "Blood_Group_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập tên nhóm máu")]
        [StringLength(255, ErrorMessage = "Độ dài tối đa là 255 ký tự")]
        [Display(Name = "Tên nhóm máu")]
        public string Name { get; set; }

        [Remote("CheckExistBloodGroupCode", "BloodGroup", ErrorMessage = "BloodGroupCodeExist", HttpMethod = "POST", AdditionalFields = "Blood_Group_ID")]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Bạn chưa nhập mã nhóm máu")]
        [Display(Name = "Mã nhóm máu ")]
        [StringLength(12, ErrorMessage = "Độ dài tối đa là 12 ký tự")]
        [RegularExpression(@"^[a-zA-Z0-9]+[a-zA-Z0-9_]*[a-zA-Z0-9]*$", ErrorMessage = "Mã nhóm máu không đúng định dạng")]
        public string Code { get; set; }

        [Display(Name = "Mô tả")]
        [StringLength(150, ErrorMessage = "Độ dài tối đa là 150 ký tự")]
        public string Descriptions { get; set; }
        public int Deleted { get; set; }
        public int RecordCount { get; set; }
        //dua ra cac truongco trong bang 
        #region
        public const string FIELD_ID = "BLOOD_GROUP_ID";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        public const string FIELD_RECORD_COUNT = "RecordCount";

        #endregion

        public BloodGroupModel()
        {
            // TODO: Complete member initialization
        }

        public BloodGroupModel(DAL.Models.Admin.BloodGroupModel model)
        {
            // TODO: Complete member initialization
            Blood_Group_ID = model.Blood_Group_ID;
            Code = model.Code;
            Name = model.Name;
            Descriptions = model.Descriptions;
            RecordCount = model.RecordCount;
            Deleted = model.Deleted;
        }


        internal DAL.Models.Admin.BloodGroupModel toDALModel()
        {
            DAL.Models.Admin.BloodGroupModel model = new DAL.Models.Admin.BloodGroupModel
            {
                Blood_Group_ID = Blood_Group_ID,
                Code = Code,
                Deleted = Deleted,
                Name = Name,
                Descriptions = Descriptions,
                RecordCount = RecordCount,
            };
            return model;
        }
    }
}